package graph.algo;

import graph.model.Graph;

public class PathProblems {

	public static void isReachable() {
		Graph graph = new Graph(5, 4, true, false);
		graph.addVertex(0, 'A');
		graph.addVertex(1, 'B');
		graph.addVertex(2, 'C');
		graph.addVertex(3, 'D');
		graph.addVertex(4, 'E');

		graph.addEdge(0, 1);
		graph.addEdge(1, 2);
		graph.addEdge(0, 3);
		graph.addEdge(3, 4);

		System.out.println("Is there a path b/w A to C ? "
				+ graph.isReachable(0, 2));
		System.out.println("Is there a path b/w A to B ? "
				+ graph.isReachable(0, 1));
		System.out.println("Is there a path b/w B to E ? "
				+ graph.isReachable(1, 4));
		System.out.println("Is there a path b/w A to E ? "
				+ graph.isReachable(0, 4));
	}

	public static void printPath() {
		Graph graph = new Graph(5, 4, true, false);
		graph.addVertex(0, 'A');
		graph.addVertex(1, 'B');
		graph.addVertex(2, 'C');
		graph.addVertex(3, 'D');
		graph.addVertex(4, 'E');

		graph.addEdge(0, 1);
		graph.addEdge(1, 2);
		graph.addEdge(0, 3);
		graph.addEdge(3, 4);

		System.out.print("Path from A to E: ");
		graph.printPath(0, 4);

		System.out.println();
		System.out.print("Path from A to C: ");
		graph.printPath(0, 2);

		System.out.println();
		System.out.print("Path from B to E: ");
		graph.printPath(1, 4);

	}

	public static void main(String[] args) {
		isReachable();

		printPath();

	}
}
